<template>
  <div class="song-audio">
    <audio :src='audioSrc' controls="controls" ref="player" preload="true"
           @canplay="startPlay"
           @timeupdate="timeupdate" @ended="ended">
    </audio>
  </div>
</template>

<script setup>
import {ref,nextTick } from 'vue'
// let props = defineProps(["audioSrc"])
let emits = defineEmits(['endPlay'])
let audioSrc = ref("")

let player = ref(null)

  function play(audioSrcTemp){
    audioSrc.value = audioSrcTemp
    nextTick(function () {
      player.value.play()
    })
  }
  function ended(){
    emits('endPlay')
  }

defineExpose({play})
</script>

<style scoped>
audio{display:none}
</style>
